#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#define FILE_SIZE 1024
int main()
{
    int fd = open("./bite", O_WRONLY | O_CREAT | O_TRUNC, 0666);
    if(fd < 0)
    {
        perror("open");
        return 1;
    }
    char str[FILE_SIZE] = {"i like linux!\n"};
    write(fd,str,strlen(str));
    close(fd);
    int fd1 = open("./bite", O_RDONLY);
    if(fd1 < 0)
    {
        perror("open");
        return 2;
    }
    char str1[FILE_SIZE] = {0};
    ssize_t s = read(fd1, str1, sizeof(str1));
    str1[s] = '\0';
    write(1, str1, strlen(str1));
    close(fd1);
    return 0;
}
